//
//  WKWebView+Architecture.m
//  ArchitectureBase
//
//  Created by lvfeijun on 2021/10/16.
//

#import "WKWebView+Architecture.h"
#import "NSString+Architecture.h"
#import "HQGlobalMacro.h"

@implementation WKWebView (Architecture)

+ (void)clearAllCahe
{
    NSSet *websiteDataTypes= [NSSet setWithArray:@[
        WKWebsiteDataTypeDiskCache,
        WKWebsiteDataTypeMemoryCache,
        WKWebsiteDataTypeOfflineWebApplicationCache
    ]];
    //清除所有的web信息
    //NSSet *websiteDataTypes = [WKWebsiteDataStore allWebsiteDataTypes];
    NSDate *dateFrom = [NSDate dateWithTimeIntervalSince1970:0];
    [[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:websiteDataTypes modifiedSince:dateFrom completionHandler:^{
        
    }];
}

+ (NSString *)hqar_getHTMLString:(NSString *)string
{
    if ([NSString hq_isEmptyString:string]) {
        return @"";
    }
    
    NSString *str0 = [NSString stringWithFormat:@"<html><head><meta name=\"viewport\" content=\"width=%f,initial-scale=1.0,maximum-scale=1.0,user-scalable=0\" />\n<link type=\"text/css\" href=\"https://oss-hqwx-edu24ol.oss-cn-beijing.aliyuncs.com/jianzhujie/css/article.reset.css\" rel=\"stylesheet\"><style>\n * {max-width:%f !important;height:auto;}\n </style>\n<base href=\"https://www.jianzhuj.cn\"></head>\n<body>",kScreen_Width - 32,kScreen_Width - 40];
    NSString *str1 = @"</body>\n</html>";
    return [NSString stringWithFormat:@"%@%@%@",str0,string,str1];
}

@end
